# 使用官方的基础镜像
#FROM ubuntu:latest

FROM arm64v8/ubuntu:latest

# 开启终端色彩
ENV TERM=xterm-256color

RUN export DEBIAN_FRONTEND=noninteractive

# 更新系统并安装Apache、MySQL和PHP
RUN apt-get update 

RUN apt-get install -y tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN dpkg-reconfigure --frontend noninteractive tzdata


RUN apt-get install -y \
    git \
    apache2 \
    # mysql-server \
    php \
    libapache2-mod-php \
    php-fpm \
    php-dev \
    php-pear \
    php-zip \
    php-curl \
    php-pdo-sqlite \
    # php-mysql \
    php-json \
    php-xml \
    php-mbstring \
    php-gd

# 允许Apache的重写模块
RUN a2enmod rewrite
# 再次安装php模块，检查apache加载情况 禁用mpm_event 保证php启动
RUN apt install libapache2-mod-php
RUN apachectl -M | grep php
RUN a2dismod mpm_event
RUN a2enmod php8.1
# 需要重启apache
# RUN /etc/init.d/apache2 restart

# 将自定义配置文件复制到Apache的配置目录中
COPY ./conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
COPY ./conf/apache2.conf /etc/apache2/apache2.conf
COPY ./conf/dir.conf /etc/apache2/mods-enabled/dir.conf
COPY ./conf/mime.conf /etc/apache2/mods-enabled/mime.conf

# 将网站文件复制到Apache的web根目录中
# COPY ./website /var/www/html/
RUN rm -rf /var/www/html
RUN git clone https://gitee.com/thinkyoung/php-start.git /var/www/html
RUN chmod 777 -R /var/www/html


# 暴露80端口供外部访问
EXPOSE 80

# 启动Apache服务器
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]